package com.yc.dept.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yc.base.BaseServiceImpl;
import com.yc.dept.entity.Dept;
import com.yc.dept.mapper.DeptMapper;
import com.yc.dept.service.IDeptService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 后台部门表 服务实现类
 * </p>
 *
 * @author bao
 * @since 2021-12-09
 */
@Service
public class DeptServiceImpl extends BaseServiceImpl<DeptMapper, Dept> implements IDeptService {
    @Override
    public boolean create(Dept dept) {
        return save(dept);
    }

    @Override
    public boolean delete(List<Long> ids) {
        return removeByIds(ids);
    }

    @Override
    public boolean update(Dept dept) {
        return updateById(dept);
    }

    @Override
    public Dept queryById(Long id) {
        return getById(id);
    }

    @Override
    public List<Dept> selectList() {
        QueryWrapper<Dept> wrapper = new QueryWrapper<>();
        wrapper.lambda().orderByDesc(Dept::getId);
        return list(wrapper);
    }

    @Override
    public IPage<Dept> selectPage(IPage<Dept> page) {
        QueryWrapper<Dept> wrapper = new QueryWrapper<>();
        wrapper.lambda().orderByDesc(Dept::getId);
        return page(page, wrapper);
    }
}
